package cjh;

import java.util.ArrayList;
import java.util.List;

import model.AdminVO;
import dao.JDBC_ConnClose;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import model.AdminVO;

import dao.JDBC_SQL;
import dao.JDBC_ConnClose;
import screen.AdminMain;
import screen.LoginMain;

public class AdminSelect {

static 	JDBC_SQL sql = new JDBC_SQL();
static StringBuilder sb = new StringBuilder();
static Scanner sc = new Scanner(System.in); 
static boolean b = true;
static String[] smt = { "순번", "ID", "이름", "연락처", "등록일자" };
static Connection conn = null;
static PreparedStatement pstmt = null;
static ResultSet rs = null;
static String add = null;
static String logId = LoginMain.logIdVO;
private static String selectSQL = "select * from ADMIN_INFO order by ADMIN_TR desc";

	public static List<AdminVO> selectMember() {
		List<AdminVO> result = new ArrayList<>();	
			try {
					
				conn = JDBC_ConnClose.openDataBase();
				pstmt = conn.prepareStatement( selectSQL );
				rs = pstmt.executeQuery();
					// 동적배열
				while( rs.next() ) {
					AdminVO m = new AdminVO();
					m.setAdmin_tr( rs.getString("ADMIN_TR") );
					m.setAdmin_id( rs.getString("ADMIN_ID") );
					m.setAdmin_name( rs.getString("ADMIN_NAME") );
					m.setAdmin_pw( rs.getString("ADMIN_PW") );
					m.setAdmin_tel( rs.getString("ADMIN_TEL") );
					m.setReg_date( rs.getString("reg_date") );
					result.add( m );
				}
				
				
		} catch ( Exception ex ) {
			ex.printStackTrace();
			
		}finally {
		
			JDBC_ConnClose.closeDataBase(conn, pstmt, rs);
		}
		
		return result;
	}
	
}
